//
//  CategoryCell.m
//  GC_OC
//
//  Created by tuibian  on 2022/5/28.
//

#import "CategoryCell.h"
#import "LinkerModel.h"

@implementation CategoryCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];


        self.container = [UIView new];
        self.container.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.container];
        
        self.playImageView = [UIImageView new];
        [self.container addSubview:self.playImageView];

        UILabel *titleLabel = [UILabel new];
        self.titleLabel = titleLabel;
        titleLabel.textColor = XHUIColorFromRGB(0x999898);
        titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        [self.container addSubview:titleLabel];
          
        [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.container.mas_right).offset(-15);
            make.centerY.equalTo(titleLabel);
            make.height.width.mas_equalTo(24);
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.container.mas_left).offset(15);
            make.top.bottom.equalTo(self.container).offset(0);
            make.right.equalTo(self.playImageView.mas_left).offset(-10);
        }];
//        

    }
    return self;
}

- (void)configCell:(LinkerModel *)info {
    self.titleLabel.text = info.name;
    
    NSNumber *isSelect = info.isSelect;
    
    self.titleLabel.textColor = XHUIColorFromRGB(0x999898);
    self.playImageView.hidden = YES;
    self.container.backgroundColor = [UIColor clearColor];
    if ([isSelect isEqual:@1]) {
        self.playImageView.hidden = NO;
        self.titleLabel.textColor = XHUIColorFromRGB(0x0091FF);
        self.container.backgroundColor = XHUIColorFromRGBA(0x32C5FF, 0.11);
    }
    
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Untitled" ofType:@"gif"];
    NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
    UIImage *image = [UIImage sd_imageWithGIFData:imageData];
    self.playImageView.image = image;
}

@end
